<!DOCTYPE html>
<html>

<head>
    <title>Preview Display</title>
    <meta charset="UTF-8">
    <!-- <link rel="shortcut icon" href="custom/images/favicon.ico?v=2" /> -->
    <style>
        html,
        body {
            padding: 0px;
            margin: 0px;
        }

        body {
            background: #000 url(./assets/兴达八厂/背景兴达.jpg) no-repeat left top;
            background-size: 100%;
        }
    </style>
    <script src='../libs/jquery-3.4.1.min.js'></script>
    <!-- <script src='../libs/message.js'></script> -->
    <script src='../custom/configs/htconfig.js'></script>
    <script src='../custom/libs/echarts.js'></script>
    <script src='../libs/core/ht.js'></script>
    <!-- <script src='../libs/plugin/ht-edgetype.js'></script> -->
    <!-- <script src='../libs/plugin/ht-obj.js'></script> -->
    <!-- <script src='../libs/core/ht-ui.js'></script> -->
    <script src='../libs/plugin/ht-vector.js'></script>
    <script src="../conf/confURL.js"></script>
    <script src='../conf/dateTime.js'></script>
    <script>
        //获取url
        var url = domain + "/HT_DATA_EIGHT.getGlobalStatistics.do";
        let deptCode = "XD1113";
        //获取图纸
        var dataModel = new ht.DataModel();
        var graphView = new ht.graph.GraphView(dataModel);
        var H = [];
        let table;
        function init() {
            graphView.addToDOM();
            ht.Default.xhrLoad('displays/智慧兴达/兴达八厂/工艺监控/process_nineFactory.json', function (text) {
                var json = ht.Default.parse(text);
                if (json.title) document.title = json.title;
                dataModel.deserialize(json);
                graphView.fitContent(true);
                tag();
                getPTKCTJ(deptCode);
                getPTTYZBTJ(deptCode);
                getSLMJXHTJ(deptCode);
                getDPDS01TJ(deptCode);
                getDPDS02TJ(deptCode);
                getMJMHTJ(deptCode);
                getRETURN();
                getMAP();
                openInterval();
            });
            //更新数据
            // setInterval(function () { getPTKCTJ() }, 1000);
            // setInterval(function () { getPTTYZBTJ() }, 1000 * 60 * 5);
            // setInterval(function () { getDPDS01TJ() }, 1000 * 60 * 30);
            setInterval(function () {
                let dateTime = dataModel.getDataByTag('time');
                let time = updateTime();
                dateTime.a('time', time);
            }, 1000);
        }
        function tag() {
            table = dataModel.getDataByTag('table');
            for (let i = 1; i < 7; i++) {
                H.push(dataModel.getDataByTag("H" + i));
            }
        }
        //盘条库存
        function getPTKCTJ(code) {
            const warn1 = dataModel.getDataByTag('warn1');
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_GY_FC_REPORT_PTKCTJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible === "true") {
                        H[0].a("title", repData.HT_GY_FC_REPORT_PTKCTJ.title);
                        warn1.s("2d.visible", false);
                        table.s("2d.visible", true);
                        table.a("Data", repData.HT_GY_FC_REPORT_PTKCTJ.data);
                    } else {
                        warn1.s("2d.visible", true);
                        table.s("2d.visible", false);
                    }
                },
                error: function (error) {
                    warn1.s("2d.visible", true);
                    table.s("2d.visible", false);
                }
            });
        }
        //盘条投用占比
        function getPTTYZBTJ(code) {
            const warn2 = dataModel.getDataByTag('warn2');
            const lineone = dataModel.getDataByTag('lineone');
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_GY_FC_REPORT_PTTYZBTJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible === "true") {
                        H[1].a("title", repData.HT_GY_FC_REPORT_PTTYZBTJ.title);
                        warn2.s("2d.visible", false);
                        lineone.s("2d.visible", true);
                        lineone.a("xData", repData.HT_GY_FC_REPORT_PTTYZBTJ.data.xdata);
                        lineone.a("data1", repData.HT_GY_FC_REPORT_PTTYZBTJ.data.A);
                        lineone.a("data2", repData.HT_GY_FC_REPORT_PTTYZBTJ.data.B);
                        lineone.a("data3", repData.HT_GY_FC_REPORT_PTTYZBTJ.data.C);
                        lineone.a("data4", repData.HT_GY_FC_REPORT_PTTYZBTJ.data.D);
                        lineone.a("data5", repData.HT_GY_FC_REPORT_PTTYZBTJ.data.S);
                    } else {
                        warn2.s("2d.visible", true);
                        lineone.s("2d.visible", false);
                    }
                },
                error: function (error) {
                    warn2.s("2d.visible", true);
                    lineone.s("2d.visible", false);
                }
            });
        }
        //湿拉磨具消耗   
        function getSLMJXHTJ(code) {
            const warn3 = dataModel.getDataByTag('warn3');
            const linetwo = dataModel.getDataByTag('linetwo');
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_GY_FC_REPORT_SLMJXHTJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible === "true") {
                        H[2].a("title", repData.HT_GY_FC_REPORT_SLMJXHTJ.title);
                        warn3.s("2d.visible", false);
                        linetwo.s("2d.visible", true);
                        linetwo.a("xAxis", repData.HT_GY_FC_REPORT_SLMJXHTJ.data.xdata);
                        linetwo.a("yAxis", repData.HT_GY_FC_REPORT_SLMJXHTJ.data.A);
                    } else {
                        warn3.s("2d.visible", true);
                        linetwo.s("2d.visible", false);
                    }
                },
                error: function (error) {
                    warn3.s("2d.visible", true);
                    linetwo.s("2d.visible", false);
                }
            });
        }
        //吨平断丝  
        function getDPDS01TJ(code) {
            const warn4 = dataModel.getDataByTag('warn4');
            const tableone = dataModel.getDataByTag('tableone');
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_GY_FC_REPORT_DPDS01TJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible === "true") {
                        H[3].a("title", repData.HT_GY_FC_REPORT_DPDS01TJ.title);
                        warn4.s("2d.visible", false);
                        tableone.s("2d.visible", true);
                        tableone.a("num", repData.HT_GY_FC_REPORT_DPDS01TJ.data.num);
                        tableone.a("gg", repData.HT_GY_FC_REPORT_DPDS01TJ.data.guige);
                    } else {
                        warn4.s("2d.visible", true);
                        tableone.s("2d.visible", false);
                    }
                },
                error: function (error) {
                    warn4.s("2d.visible", true);
                    tableone.s("2d.visible", false);
                }
            });
        }
        //吨平断丝
        function getDPDS02TJ(code) {
            const warn5 = dataModel.getDataByTag('warn5');
            const linethree = dataModel.getDataByTag('linethree');
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_GY_FC_REPORT_DPDS02TJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible === "true") {
                        H[4].a("title", repData.HT_GY_FC_REPORT_DPDS02TJ.title);
                        warn5.s("2d.visible", false);
                        linethree.s("2d.visible", true);
                        linethree.a("xData", repData.HT_GY_FC_REPORT_DPDS02TJ.data.xdata);
                        linethree.a("data1", repData.HT_GY_FC_REPORT_DPDS02TJ.data.HT);
                        linethree.a("data2", repData.HT_GY_FC_REPORT_DPDS02TJ.data.NT);
                        linethree.a("data3", repData.HT_GY_FC_REPORT_DPDS02TJ.data.ST);
                        linethree.a("data4", repData.HT_GY_FC_REPORT_DPDS02TJ.data.UT);
                        linethree.a("value1", repData.HT_GY_FC_REPORT_DPDS02TJ.data.HT实际产量);
                        linethree.a("value2", repData.HT_GY_FC_REPORT_DPDS02TJ.data.NT实际产量);
                        linethree.a("value3", repData.HT_GY_FC_REPORT_DPDS02TJ.data.HT断丝次数);
                        linethree.a("value4", repData.HT_GY_FC_REPORT_DPDS02TJ.data.NT断丝次数);
                        linethree.a("value5", repData.HT_GY_FC_REPORT_DPDS02TJ.data.ST实际产量);
                        linethree.a("value6", repData.HT_GY_FC_REPORT_DPDS02TJ.data.UT实际产量);
                        linethree.a("value7", repData.HT_GY_FC_REPORT_DPDS02TJ.data.ST断丝次数);
                        linethree.a("value8", repData.HT_GY_FC_REPORT_DPDS02TJ.data.UT断丝次数);
                    } else {
                        warn5.s("2d.visible", true);
                        linethree.s("2d.visible", false);
                    }
                },
                error: function (error) {
                    warn5.s("2d.visible", true);
                    linethree.s("2d.visible", false);
                }
            });
        }
        //模具模耗
        function getMJMHTJ(code) {
            const linefour = dataModel.getDataByTag('linefour');
            const warn6 = dataModel.getDataByTag('warn6');
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_GY_FC_REPORT_MJMHTJ",
                    deptCode: code
                },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.visible === "true") {
                        H[5].a("title", repData.HT_GY_FC_REPORT_MJMHTJ.title);
                        warn6.s("2d.visible", false);
                        linefour.s("2d.visible", true);
                        linefour.a("xAxis", repData.HT_GY_FC_REPORT_MJMHTJ.data.xdata);
                        linefour.a("yAxis1", repData.HT_GY_FC_REPORT_MJMHTJ.data.cl);
                        linefour.a("yAxis2", repData.HT_GY_FC_REPORT_MJMHTJ.data.zl);
                        linefour.a("yAxis3", repData.HT_GY_FC_REPORT_MJMHTJ.data.ll);
                    } else {
                        warn6.s("2d.visible", true);
                        linefour.s("2d.visible", false);
                    }
                },
                error: function (error) {
                    warn6.s("2d.visible", true);
                    linefour.s("2d.visible", false);
                }
            });
        }
        //返回按钮
        function getRETURN() {
            const backButton = dataModel.getDataByTag("backButton");
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_GY_FC_BUTTON_RETURN"
                },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.HT_GY_FC_BUTTON_RETURN.visible === "true") {
                        backButton.a("url", repData.HT_GY_FC_BUTTON_RETURN.data.url);
                        backButton.s("2d.visible", repData.HT_GY_FC_BUTTON_RETURN.visible);
                    }
                },
                error: function (error) {
                    // console.log('err');
                }
            });
        }
        //中间3车间      
        function getMAP() {
            let text11 = dataModel.getDataByTag("text1-1");
            let text12 = dataModel.getDataByTag("text1-2");
            let text21 = dataModel.getDataByTag("text2-1");
            let text22 = dataModel.getDataByTag("text2-2");
            let text3 = dataModel.getDataByTag("text3");
            let text4 = dataModel.getDataByTag("text4");
            let work11 = dataModel.getDataByTag("work1-1");
            let work12 = dataModel.getDataByTag("work1-2");
            const work21 = dataModel.getDataByTag("work2-1");
            const work22 = dataModel.getDataByTag("work2-2");
            const work3 = dataModel.getDataByTag("work3");
            const work4 = dataModel.getDataByTag("work4");
            var repData = {};
            $.ajax({
                type: "POST",
                url: url,
                data: {
                    props: "HT_GY_ZZ_FC_MAP",
                    deptCode: deptCode
                },
                headers: request_headers,
                async: true,
                contentType: 'application/x-www-form-urlencoded',
                success: function (res) {
                    repData = JSON.parse(res);
                    if (repData._MSG_ === 'OK' && repData.HT_GY_ZZ_FC_MAP.visible === "true") {
                        work11.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        work12.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        work21.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        work22.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        work3.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        work4.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        text11.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        text12.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        text21.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        text22.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        text3.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                        text4.s("label", repData.HT_GY_ZZ_FC_MAP.urlMap);
                    }
                },
                error: function (error) {
                    // console.log('err');
                }
            });
        }
        //表格自动滚动
        function tableRun() {
            let tabledata = table.a("Data");
            var old = table.a('ht.translateY');
            table.a('ht.translateY', old - 44);
            tabledata.push(tabledata[0]);
            tabledata.splice(0, 1)
            table.a("Data", tabledata);
            table.a('ht.translateY', old);
        }
        //重新打开定时器，播放滚动
        function openInterval() {
            tableTimer = setInterval(tableRun, 2000);
        }


    </script>
</head>

<body onload='setTimeout(init, 300)'>
</body>

</html>